package com.eshop.modules.shop.service.impl;

import org.slf4j.LoggerFactory;
import java.lang.invoke.SerializedLambda;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.slf4j.Logger;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import com.eshop.modules.shop.service.SystemAttachmentService;
import com.eshop.modules.shop.domain.SystemAttachment;
import com.eshop.modules.shop.service.mapper.SystemAttachmentMapper;
import com.eshop.common.service.impl.BaseServiceImpl;

@Service
@Transactional(rollbackFor = { Exception.class })
public class SystemAttachmentServiceImpl extends BaseServiceImpl<SystemAttachmentMapper, SystemAttachment> implements SystemAttachmentService
{
    private static final Logger log;
    private final SystemAttachmentMapper systemAttachmentMapper;
    
    public SystemAttachment getInfo(final String name) {
        final LambdaQueryWrapper<SystemAttachment> wrapper = (LambdaQueryWrapper<SystemAttachment>)new LambdaQueryWrapper();
        ((LambdaQueryWrapper)wrapper.eq(SystemAttachment::getName, (Object)name)).last("limit 1");
        return (SystemAttachment)this.systemAttachmentMapper.selectOne(wrapper);
    }
    
    public SystemAttachment getByCode(final String code) {
        final LambdaQueryWrapper<SystemAttachment> wrapper = (LambdaQueryWrapper<SystemAttachment>)new LambdaQueryWrapper();
        ((LambdaQueryWrapper)wrapper.eq(SystemAttachment::getInviteCode, (Object)code)).last("limit 1");
        return (SystemAttachment)this.systemAttachmentMapper.selectOne((Wrapper)wrapper);
    }
    
    public void attachmentAdd(final String name, final String attSize, final String attDir, final String sattDir) {
        final SystemAttachment attachment = SystemAttachment.builder().name(name).attSize(attSize).attDir(attDir).attType("image/jpeg").sattDir(sattDir).build();
        this.systemAttachmentMapper.insert(attachment);
    }
    
    public void newAttachmentAdd(final String name, final String attSize, final String attDir, final String sattDir, final Long uid, final String code) {
        final SystemAttachment attachment = SystemAttachment.builder().name(name).attSize(attSize).attDir(attDir).attType("image/jpeg").sattDir(sattDir).uid(uid).inviteCode(code).build();
        this.systemAttachmentMapper.insert(attachment);
    }
    
    public SystemAttachmentServiceImpl(final SystemAttachmentMapper systemAttachmentMapper) {
        this.systemAttachmentMapper = systemAttachmentMapper;
    }
    
    static {
        log = LoggerFactory.getLogger((Class)SystemAttachmentServiceImpl.class);
    }
}
